#pragma once

template<class iterator, class Ref, class Ptr>
struct ReverseIterator
{
	typedef ReverseIterator<class iterator, class Ref, class Ptr> self;

	iterator _it;

	ReverseIterator(iterator it)
		:_it(it)
	{}

	self& operator++()
	{
		--_it;
		return *this;
	}

	self operator++(int)
	{
		self tmp(_it);
		++this;
		return tmp;
	}

	self& operator--()
	{
		++_it;
		return *this;
	}

	self operator--(int)
	{
		self tmp(_it);
		--this;
		return tmp;
	}

	Ref operator*()
	{
		iterator tmp = _it;
		return *(--tmp);
	}

	Ptr operator->()
	{
		return _it.operator->();
	}

	bool operator!= (const self& s)
	{
		return _it != s._it;
	}
	bool operator== (const self& s)
	{
		return _it == s._it;
	}
};
